#include<bits/stdc++.h>
using namespace std;

string in,post;
string f(string in,string post){
	if(in.empty()) return "";
	string inleft="",inright="";
	string postleft="",postright="";
	int len=post.length();
	char c=post[len-1];
	int i=0;
	//
	while(in[i]!=c){
		inleft+=in[i];
		i++;
	}
	i++;
	while(in[i]!='\0'){
		inright+=in[i];
		i++;
	}
	//
	i=0;
	len=inleft.length();
	while(i<inleft.length()){
		postleft+=post[i];
		i++;
	}
	while(post[i+1]!='\0'){
		postright+=post[i];
		i++;		
	}
	return c+f(inleft,postleft)+f(inright,postright);
}

int main(){
	cin>>in>>post;
	cout<<f(in,post);
}
